package com.wa.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * 日志类型枚举
 * @Author Dawn
 * @Date 2021/10/19 10:02
 */
public enum LogTypeEnum {
    /** -----变更日志------ */
    C_ADD(10, "add", "新增", LogCategoryEnum.CHANGE.getStatusCode()),
    C_EDIT(20, "edit", "编辑", LogCategoryEnum.CHANGE.getStatusCode()),
    C_DELETE(30, "delete", "删除", LogCategoryEnum.CHANGE.getStatusCode()),
    C_BATCH_EDIT(40, "batch edit", "批量编辑", LogCategoryEnum.CHANGE.getStatusCode()),

    /** -----操作日志------ */
    O_ADD(1010, "add", "新增", LogCategoryEnum.OPERATION.getStatusCode()),
    O_EDIT(1020, "edit", "编辑", LogCategoryEnum.OPERATION.getStatusCode()),
    O_DELETE(1030, "delete", "删除", LogCategoryEnum.OPERATION.getStatusCode()),
    O_APPROVE(1040, "approve", "审核通过", LogCategoryEnum.OPERATION.getStatusCode()),
    O_REJECT(1050, "reject", "审核不通过", LogCategoryEnum.OPERATION.getStatusCode()),
    O_ENABLE(1060, "enable", "启用", LogCategoryEnum.OPERATION.getStatusCode()),
    O_DISABLE(1070, "disable", "禁用", LogCategoryEnum.OPERATION.getStatusCode()),
    O_EDIT_PASSWORD(1080, "edit password", "修改密码", LogCategoryEnum.OPERATION.getStatusCode()),
    O_UNLOCK(1090, "unlock", "解锁", LogCategoryEnum.OPERATION.getStatusCode()),
    O_LOCK(1100, "lock", "锁定", LogCategoryEnum.OPERATION.getStatusCode()),
    O_LOGIN(1110, "login", "登录", LogCategoryEnum.OPERATION.getStatusCode()),
    O_RELEVANCE(1120, "relevance", "账号关联", LogCategoryEnum.OPERATION.getStatusCode()),
    O_CANCEL_RELEVANCE(1130, "cancel relevance", "取消关联", LogCategoryEnum.OPERATION.getStatusCode()),
    O_EXPORT(1140, "export", "导出", LogCategoryEnum.OPERATION.getStatusCode()),
    O_BATCH_EDIT(1150, "batch edit", "批量编辑", LogCategoryEnum.OPERATION.getStatusCode()),
    O_UNSHELVE_GOODS(1160, "unshelve goods", "商品下架", LogCategoryEnum.OPERATION.getStatusCode()),
    O_SHELVE_GOODS(1170, "shelve goods", "商品上架", LogCategoryEnum.OPERATION.getStatusCode()),
    O_BATCH_UNSHELVE_GOODS(1180, "batch unshelve goods", "批量商品下架", LogCategoryEnum.OPERATION.getStatusCode()),
    O_BATCH_SHELVE_GOODS(1190, "batch shelve goods", "批量商品上架", LogCategoryEnum.OPERATION.getStatusCode()),
    O_RESET_PASSWORD(1200, "reset password", "重置密码", LogCategoryEnum.OPERATION.getStatusCode()),
    O_MERGE_DEPT(1210, "merge department", "合并部门", LogCategoryEnum.OPERATION.getStatusCode()),

    /** -----消息日志------ */
    EMAIL(2010, "email", "邮件", LogCategoryEnum.MSG.getStatusCode()),
    SMS(2020, "SMS", "短信", LogCategoryEnum.MSG.getStatusCode()),
    ;

    private int statusCode;
    private String statusMsgEn;
    private String statusMsgCn;
    /**
     * 日志种类
     */
    private int categoryCode;

    LogTypeEnum(int statusCode, String statusMsgEn, String statusMsgCn, int categoryCode) {
        this.statusCode = statusCode;
        this.statusMsgEn = statusMsgEn;
        this.statusMsgCn = statusMsgCn;
        this.categoryCode = categoryCode;
    }

    private static final Map<Integer, LogTypeEnum> LOOK_UP = new HashMap<>();

    static {
        for (LogTypeEnum ase : LogTypeEnum.values()) {
            LOOK_UP.put(ase.getStatusCode(), ase);
        }
    }

    public int getStatusCode() {
        return statusCode;
    }

    public String getStatusMsgEn() {
        return statusMsgEn;
    }

    public String getStatusMsgCn() {
        return statusMsgCn;
    }

    public int getCategoryCode() {
        return categoryCode;
    }

    public static LogTypeEnum get(Integer statusCode) {
        return LOOK_UP.get(statusCode);
    }
}
